#include <stdio.h>
#include <time.h>
#include "logtime.h"


unsigned long int t0;

float vet_time[4];

int iter;

void initlogtime(){
	t0 = clock();
}

void regtime(int n){
	unsigned long int t1;
	t1 = clock();

	vet_time[n] = ((double) (t1 - t0))/CLOCKS_PER_SEC;
	t0 = t1;
}

void setit(int i){
	iter = i;
}

void savelog(const char * file, const char * logfile){
	FILE * fp;

	fp = fopen(logfile, "a");
	if(fp == NULL) {
		perror("Erro logfile");
		return;
	}

	fprintf(fp, "%s\t%.3lf\t%.3lf\t%.3lf\t%.3lf\t%.3lf\t%d\n",
			file, vet_time[0] + vet_time[1] + vet_time[2] + vet_time[3],
			vet_time[0], vet_time[1], vet_time[2], vet_time[3], iter);

	fclose(fp);
}
